package com.bh.web.controller.extend;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.common.utils.poi.ExcelUtil;
import com.bh.extend.domain.JcVehicleHeadFixRecord;
import com.bh.extend.service.IJcVehicleHeadFixRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆维修记录Controller
 * 
 * @author slx
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/extend/fixRecord")
public class JcVehicleHeadFixRecordController extends BaseController
{
    @Autowired
    private IJcVehicleHeadFixRecordService jcVehicleHeadFixRecordService;

    /**
     * 查询车辆维修记录列表
     */
    @ApiOperation("查询车辆维修记录列表")
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcVehicleHeadFixRecord jcVehicleHeadFixRecord)
    {
        startPage();
        List<JcVehicleHeadFixRecord> list = jcVehicleHeadFixRecordService.selectJcVehicleHeadFixRecordList(jcVehicleHeadFixRecord);
        return getDataTable(list);
    }

    /**
     * 导出车辆维修记录列表
     */
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:export')")
    @Log(title = "车辆维修记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcVehicleHeadFixRecord jcVehicleHeadFixRecord)
    {
        List<JcVehicleHeadFixRecord> list = jcVehicleHeadFixRecordService.selectJcVehicleHeadFixRecordList(jcVehicleHeadFixRecord);
        ExcelUtil<JcVehicleHeadFixRecord> util = new ExcelUtil<>(JcVehicleHeadFixRecord.class);
        util.exportExcel(response, list, "车辆维修记录数据");
    }

    /**
     * 获取车辆维修记录详细信息
     */
    @ApiOperation("获取车辆维修记录详细信息")
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcVehicleHeadFixRecordService.selectJcVehicleHeadFixRecordById(id));
    }

    /**
     * 新增车辆维修记录
     */
    @ApiOperation("新增车辆维修记录")
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:add')")
    @Log(title = "车辆维修记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcVehicleHeadFixRecord jcVehicleHeadFixRecord)
    {
        return toAjax(jcVehicleHeadFixRecordService.insertJcVehicleHeadFixRecord(jcVehicleHeadFixRecord));
    }

    /**
     * 修改车辆维修记录
     */
    @ApiOperation("修改车辆维修记录")
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:edit')")
    @Log(title = "车辆维修记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcVehicleHeadFixRecord jcVehicleHeadFixRecord)
    {
        return toAjax(jcVehicleHeadFixRecordService.updateJcVehicleHeadFixRecord(jcVehicleHeadFixRecord));
    }

    /**
     * 删除车辆维修记录
     */
    @ApiOperation("删除车辆维修记录")
    @PreAuthorize("@ss.hasPermi('extend:fixRecord:remove')")
    @Log(title = "车辆维修记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcVehicleHeadFixRecordService.deleteJcVehicleHeadFixRecordByIds(ids));
    }
}
